<?php

require_once dirname(__FILE__) . '/autoload.php';

function getSearchEngineIndexCount($domain) {
    $result = array();
    $baiduURL = 'http://www.baidu.com/s?ie=utf-8&wd=site%3A' . $domain;

    $pBaidu = '#百度为您找到相关结果约(.*)个#isU';
    $sBaidu = file_get_contents($baiduURL);
    preg_match_all($pBaidu, $sBaidu, $dBaidu);
    $result['baidu_site'] = $dBaidu[1][0];

    $googleURL = 'http://www.google.com.hk/search?newwindow=1&safe=strict&site=&source=hp&q=site%3A' . $domain . '&';
    $pGoogle = '#找到约(.*)条结果#isU';
    $sGoogle = file_get_contents($googleURL);
    echo $sGoogle;
    preg_match_all($pBaidu, $sGoogle, $dGoogle);
    $result['google_site'] = $dGoogle[1][0];

    return $result;
}

var_dump(getSearchEngineIndexCount('sina.com'));
?>